// app.js
App({
  routerGuard: {
    beforeEach(to, from, next) {
      console.log("wx.getStorageSync('token')",wx.getStorageSync('token'))
      if (!wx.getStorageSync('token')) {
        wx.navigateTo({
          url: '/pages/pre_index/index'
        });
      } else {
        console.log('to.route', to.route)
        if(to.route == "pages/pre_index/index" && wx.getStorageSync('token') && wx.getStorageSync('postCode')){
          if(wx.getStorageSync('postCode') == "004"){
            wx.navigateTo({
              url: '/pages/bus_index/index'
            });
          }else{
            wx.navigateTo({
              url: '/pages/work_index/index'
            });
          }
        }
       // next();
      }
    },
    afterEach(to, from) {
      console.log('after each');
    }
  },
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  //全局属性
  globalData: {
    userInfo: null,
    markers:[],//地图选中的位置
  }
})
